package day20170427;

import java.lang.reflect.Constructor;

import org.junit.Test;

public class ConstructorTest {
	@Test
	public void constructorTest() throws Exception {
		//1.拿到照妖镜
		Class clazz = Class.forName("day20170427.Student");
		//获取到学生对象
		Student student = (Student) clazz.newInstance();
		//获取指定的构造方法
		Constructor con = clazz.getDeclaredConstructor(Integer.class,String.class);
		//对构造方法进行复制
		Object newInstance = con.newInstance(100,"张三");
		//这个相当于调用了Student中的toString方法
		System.out.println(newInstance);
	}
}
